<?php
auth_redirect();
global $db_query;
$post_q = $db_query->query_vars['q'];
check_user_can_editpost($post_q);


$xajax = new xajax(); 
//$xajax->debugOn(); // Uncomment this line to turn debugging on
$xajax->registerFunction("logoutFunc");
$xajax->registerFunction("addUrlInput");
$xajax->registerFunction("removeUrlInput");
$xajax->registerFunction("processEditPostForm");
$xajax->processRequests();
?>

<?php get_header(); ?>

<DIV id=container>
<BR/>

<DIV id=contents>
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>	

<H2><A href="<?=get_option('siteurl')?>">首页</A> &#187; 编辑文章 "<?php the_post_title(); ?>"</H2>

<form id="submitform1" action="javascript:void(null);" onsubmit="submitEditPost();">

<FIELDSET>
<LEGEND><SPAN class=sign>编辑文章</SPAN></LEGEND>

<br/><span class="l-mid">
<label for="url" accesskey="1">原文链接(URL):</label><br />
<span id="addonurl">
<input type="text" name=submiturl id=submiturl value="<?php the_post_url(); ?>" class="form-full" />
<SPAN class=cursor_pointer onclick="javascript:xajax_addUrlInput(document.getElementById('addonurlcount').value);"><IMG border=0 align=absmiddle  src="<?php bloginfo('stylesheet_directory'); ?>/img/create-small.gif"/></SPAN>
<?php get_added_urls_inputbox(); ?>
</span>

<br />
<span class="form-note">如果要增加更多链接地址(URL)，请点击右面的加号</span>
<span class="form-note">如果要删除附加链接地址(URL)，请点击右面的减号</span>
<span id="spanurlcount"><input type="hidden" name="addonurlcount" value="<?php get_added_urls_number(); ?>"></span>
</span>
<span id="checkurlmsg"></span>

<br/><span class="l-mid">
<label for="title" accesskey="2">标题:</label><br />
<span class="form-note">(最多 75 字符)</span></span>
<input type="text" id="title" name="title" value="<?php the_post_title(); ?>" size="60" maxlength="75" class="form-full"/><br />
<span id="checktitlemsg"></span>

<p class="l-mid">
<label for="bodytext" accesskey="3">简介:</label>
<span class="form-note">给你提交的文章一个简单描述,可以是拷贝文章开头的几句话,或者是你自己的评论.</span>
<textarea name="bodytext" rows="14" cols="70" id="bodytext" class="form-full"><?=filter_bodytext_converse(the_content(false)); ?></textarea></p>
<span id="checkdesmsg"></span>

<p class="l-mid">
<label for="category" accesskey="6">标签:</label>
<br /><span class="form-note">输入相关的标签的名称.(用空格分割)</span>
<input type="text" id="place" name="place" value="<?php get_post_tags(false); ?>" size="60" class="form-full"/></p>
<span id="checkplacemsg"></span>

<input type="hidden" name="post_id" value="<?php the_post_id(); ?>">
</fieldset>

<input type="submit" name="submit1" value="提交">

</FORM>

	<?php endwhile; else: ?>
		<?php header("location:./"); ?>
	<?php endif; ?>

</DIV>

<?php get_footer(); ?>

